//封装一个储存的方法



let set  = (key,value)=>{
    if(key && value){
        try{
            let json = JSON.stringify(value)
            localStorage.setItem(key,json)
        }catch(e){
            console.error(e)
        }
    }else{
        console.log("key和value必须传递");
    }
}

let get = key =>{
    let res = localStorage.getItem(key);
    try{
        let result = JSON.parse(res)
        return result
    } catch(e){
        console.log(e);
        return res
    }
}
//封装一个方法，用于存储用户的信息和token
let storageUserInfo = ({userInfo,token,permission})=>{
    set("userInfo",userInfo)
    set('qf-token',token)
    set('permission',permission)
  }

export default{
    set,
    get,
    storageUserInfo
}